clc;clear;clearvars;
load('lonosphere_X.mat', 'ionosphere');
data_x = ionosphere;
load('lonosphere_Y.mat', 'ionosphere1');
data_y = ionosphere1;
% load('Vehicle_X.mat')
% load('Vehicle_Y.mat')
% data_x = xaa;
% data_y = xaa1;
% load('sonar_X.mat')
% data_x = sonar1;
% load('sonar_Y.mat')
% data_y = sonar1;
% load('Beast-cancer_X.mat')
% data_x = UCIBeastcancerwdbc;
% load('Beast-cancer_Y.mat')
% data_y = UCIBeastcancerwdbc;
num_lable = 2;
num_simple = 20;
num_iter = 100;
num_feature = size(data_x, 2);
best_Z1 = zeros(1, num_feature);
best_acc1 = 0;
Fmin1 = zeros(num_iter, 1);
stage1 = zeros(num_iter, 1);
for i = 1 : 10
% for i = 1
    [best_Zi, best_acc, Fmin, stage] = Bi_BPSO(num_simple, num_iter, num_feature, data_x, data_y, num_lable);
    if best_acc > best_acc1
        best_acc1 = best_acc;
        best_Z1 = best_Zi;
        Fmin1 = Fmin;
        stage1 = stage;
    end
end
best_feature = find(best_Z1 == 1);
disp(sum(best_Z1));
disp(best_feature);
disp(best_acc1);
plot(Fmin);